package com.cgtong.android.activity;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cgtong.android.App;
import com.cgtong.android.R;
import com.cgtong.android.base.BaseActivity;
import com.cgtong.android.db.UserAccount;
import com.cgtong.android.util.CommonUtils;
import com.umeng.analytics.MobclickAgent;

import butterknife.BindView;
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * 问题反馈详情
 */
public class MyAdviseDetailActivity extends BaseActivity {

    @BindView(R.id.title_center_txt)
    TextView mTitleCenterTxt;
    @BindView(R.id.tv_content)
    TextView tv_content;
    @BindView(R.id.tv_time)
    TextView tv_time;
    @BindView(R.id.tv_username)
    TextView tv_name;
    @BindView(R.id.user_head)
    CircleImageView iv_head;

    @BindView(R.id.tv_reply_time)
    TextView tv_reply_time;
    @BindView(R.id.tv_reply_content)
    TextView tv_reply_content;

    @BindView(R.id.reply_layout)
    RelativeLayout mReplyLayout;

    @OnClick(R.id.title_left_txt)
    public void onViewClicked(View view) {
        finish();
    }

    public static void start2Activity(Context context, String content, String time
        ,String replytime,String replycontent){
        Intent intent = new Intent(context, MyAdviseDetailActivity.class);
        intent.putExtra("content", content);
        intent.putExtra("time", time);
        intent.putExtra("replytime", replytime);
        intent.putExtra("replycontent", replycontent);
        context.startActivity(intent);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_advise_detail;
    }

    @Override
    public void initData() {
        mTitleCenterTxt.setText(getString(R.string.title_advise));
        tv_content.setText(getIntent().getStringExtra("content"));
        tv_time.setText(getIntent().getStringExtra("time"));
        String replyTime =getIntent().getStringExtra("replytime");
        String replyContent =getIntent().getStringExtra("replycontent");

        UserAccount account = App.getInstance().getCurrentAccount();
        if (account != null) {
            tv_name.setText(account.getName());
            CommonUtils.setUserAvatar(MyAdviseDetailActivity.this, iv_head, account.getAvatarId());
        }
        if(!TextUtils.isEmpty(replyTime) && !TextUtils.isEmpty(replyContent)){
             tv_reply_time.setText(replyTime);
             tv_reply_content.setText(replyContent);
             mReplyLayout.setVisibility(View.VISIBLE);
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onPageStart("建议详情");
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd("建议详情");
        MobclickAgent.onPause(this);
    }
}